# ************************************
# Vhost template in module puppetlabs-apache
# Managed by Puppet
# ************************************

<VirtualHost <%= @nvh_addr_port %>>
  ServerName <%= @servername %>
<% if @serveradmin -%>
  ServerAdmin <%= @serveradmin %>
<% end -%>

  ## Vhost docroot
<% if @virtual_docroot -%>
  VirtualDocumentRoot "<%= @virtual_docroot %>"
<% else -%>
  DocumentRoot "<%= @docroot %>"
<% end -%>
<%= scope.function_template(['apache/vhost/_aliases.erb']) -%>

<%= scope.function_template(['apache/vhost/_itk.erb']) -%>

<% if @fallbackresource -%>
  FallbackResource <%= @fallbackresource %>
<% end -%>
<%- if @allow_encoded_slashes -%>
  AllowEncodedSlashes <%= @allow_encoded_slashes %>
<%- end -%>

  ## Directories, there should at least be a declaration for <%= @docroot %>
<%= scope.function_template(['apache/vhost/_directories.erb']) -%>

  ## Load additional static includes
<% Array(@additional_includes).each do |include| -%>
  Include "<%= include %>"
<% end -%>

  ## Logging
<% if @error_log -%>
  ErrorLog "<%= @error_log_destination %>"
<% end -%>
<% if @log_level -%>
  LogLevel <%= @log_level %>
<% end -%>
  ServerSignature Off
<% if @access_log and @_access_log_env_var -%>
  CustomLog "<%= @access_log_destination %>" <%= @_access_log_format %> <%= @_access_log_env_var %>
<% elsif @access_log -%>
  CustomLog "<%= @access_log_destination %>" <%= @_access_log_format %>
<% end -%>
<%= scope.function_template(['apache/vhost/_action.erb']) -%>
<%= scope.function_template(['apache/vhost/_block.erb']) -%>
<%= scope.function_template(['apache/vhost/_error_document.erb']) -%>
<%= scope.function_template(['apache/vhost/_proxy.erb']) -%>
<%= scope.function_template(['apache/vhost/_rack.erb']) -%>
<%= scope.function_template(['apache/vhost/_redirect.erb']) -%>
<%= scope.function_template(['apache/vhost/_rewrite.erb']) -%>
<%= scope.function_template(['apache/vhost/_scriptalias.erb']) -%>
<%= scope.function_template(['apache/vhost/_serveralias.erb']) -%>
<%= scope.function_template(['apache/vhost/_setenv.erb']) -%>
<%= scope.function_template(['apache/vhost/_ssl.erb']) -%>
<%= scope.function_template(['apache/vhost/_suphp.erb']) -%>
<%= scope.function_template(['apache/vhost/_php_admin.erb']) -%>
<%= scope.function_template(['apache/vhost/_header.erb']) -%>
<%= scope.function_template(['apache/vhost/_requestheader.erb']) -%>
<%= scope.function_template(['apache/vhost/_wsgi.erb']) -%>
<%= scope.function_template(['apache/vhost/_custom_fragment.erb']) -%>
<%= scope.function_template(['apache/vhost/_fastcgi.erb']) -%>
<%= scope.function_template(['apache/vhost/_suexec.erb']) -%>
</VirtualHost>
